<template>
  <div class="in-master-print" ref="print">
    <div class="print-mid">
      <div class="mid-l">
        <h3>{{ title }}</h3>
        <h2>{{ printData.workTypeTran }}</h2>
        <p>
          <label>单据编码：</label>
          <span>{{ printData.wmCode }}</span>
        </p>
        <p>
          <label>单据日期：</label>
          <span>{{ printData.invoiceDate }}</span>
        </p>
        <p>
          <label>仓库：</label>
          <span>{{ printData.warehouse }}</span
          ><span style="display: inline-block; margin-left: 15px">{{
            printData.bredVouch | filterBredVouch
          }}</span>
        </p>
      </div>
      <div class="mid-m" v-if="printData.bredVouch == '0'">
        <p v-if="printData.workType == '0'">
          <label>到货单号：</label>
          <span>{{ printData.poCheckinCode }}</span>
        </p>
        <p v-if="printData.workType == '0'">
          <label>供方：</label>
          <span>{{ printData.supplier }}</span>
        </p>
        <p v-if="printData.workType == '1'">
          <label>生产单号：</label>
          <span>{{ printData.prsCheckinCode }}</span>
        </p>
        <p v-if="printData.workType == '2'">
          <label>到货单号：</label>
          <span>{{ printData.puCheckinCode }}</span>
        </p>

        <p v-if="printData.workType == '2'">
          <label>外协厂家：</label>
          <span>{{ printData.outSource }}</span>
        </p>
        <p>
          <label>备注：</label>
          <span>{{ printData.remarks }}</span>
        </p>
      </div>
      <!-- 红字 -->
      <div class="mid-m" v-if="printData.bredVouch == '1'">
        <p>
          <label>退货单号：</label>
          <span>{{ printData.omRejectCode }}</span>
        </p>

        <p v-if="printData.workType == '0'">
          <label>销售客户：</label>
          <span>{{ printData.customer }}</span>
        </p>

        <p v-if="printData.workType == '2'">
          <label>外协厂家：</label>
          <span>{{ printData.outSource }}</span>
        </p>

        <p>
          <label>备注：</label>
          <span>{{ printData.remarks }}</span>
        </p>
      </div>
      <!-- 黄字 -->
      <div class="mid-m" v-if="printData.bredVouch == '2'">
        <p>
          <label>备注：</label>
          <span>{{ printData.remarks }}</span>
        </p>
      </div>
      <div class="mid-r">
        <img src="../../assets/images/ewm.png" />
      </div>
    </div>
    <table cellspacing="0" cellpadding="0">
      <thead>
        <tr>
          <th>序号</th>
          <th>物料编码</th>
          <th>物料名称</th>
          <th>主计量</th>
          <th>数量</th>
          <th v-if="wmSpecail.length > 0">
            {{ wmSpecail[0] }}
          </th>
          <th v-if="wmSpecail.length > 1">
            {{ wmSpecail[1] }}
          </th>
          <th v-if="wmSpecail.length > 2">
            {{ wmSpecail[2] }}
          </th>
          <th v-if="wmSpecail.length > 3">
            {{ wmSpecail[3] }}
          </th>
          <th v-if="wmSpecail.length > 4">
            {{ wmSpecail[4] }}
          </th>
          <th v-if="locationStatus">货位</th>
          <th>备注</th>
        </tr>
      </thead>
      <tbody v-if="printData.wmInSalveList.length > 0">
        <tr v-for="(item, id) in printData.wmInSalveList" :key="id">
          <td class="inv-id">{{ item.id }}</td>
          <td>{{ item.invCode }}</td>
          <td>{{ item.invName }}{{ item.invAttribute }}</td>
          <td>{{ item.unitName }}</td>
          <td>{{ item.quantity }}</td>

          <td v-if="wmSpecail.length > 0">
            {{ item.f1 }}
          </td>
          <td v-if="wmSpecail.length > 1">
            {{ item.f2 }}
          </td>
          <td v-if="wmSpecail.length > 2">
            {{ item.f3 }}
          </td>
          <td v-if="wmSpecail.length > 3">
            {{ item.f4 }}
          </td>
          <td v-if="wmSpecail.length > 4">
            {{ item.f5 }}
          </td>
          <td v-if="locationStatus">{{ item.location }}</td>
          <td>{{ item.remarks }}</td>
        </tr>
      </tbody>
    </table>
    <div class="print-bot">
      <div class="bot-l">
        <label>制单人：</label>
        <span>{{ printData.warehouseOper }}</span>
      </div>
      <div class="bot-m">
        <label>审核人：</label>
        <span>{{ printData.warehouseCheck }}</span>
      </div>
      <div class="bot-r">
        <label>打印日期：</label>
        <span>{{ printData.printTime }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    // 打印数据
    printData: {
      type: Object,
      default() {
        return {};
      },
    },
    // 标题
    title: {
      type: String,
      default() {
        return "入库单";
      },
    },
    //特殊属性
    wmSpecail: {
      type: Array,
      default() {
        return [];
      },
    },
    // 货位状态
    locationStatus: {
      type: Boolean,
      default() {
        return true;
      },
    },
    // 单价状态
    priceStatus: {
      type: Boolean,
      default() {
        return true;
      },
    },
    //仓库对应分类信息
    wmSort: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  filters: {
    filterBredVouch(n) {
      switch (n) {
        case "0":
          return "蓝字";
          break;
        case "1":
          return "红字";
          break;
        case "2":
          return "黄字";
          break;
        default:
          return "蓝字";
      }
    },
  },
};
</script>

